package com.feiyi.app.adapter.goodsdetail;

import android.support.annotation.Nullable;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.feiyi.app.R;
import com.feiyi.app.bean.GoodsDetailBean;
import com.feiyi.app.glideutils.GlideImgManager;
import com.feiyi.app.utils.ImageUtil;

import java.util.List;

import de.hdodenhof.circleimageview.CircleImageView;

/**
 * 作者 : wlt
 * 创建时间:  2018-07-25
 * QQ : 1346947404
 * 邮箱:wanglt_android@163.com
 * 类说明:
 * In me the tiger sniffs the rose
 */

public class GoodsCommentAdapter extends BaseQuickAdapter<GoodsDetailBean.DataBean.CommentsBean,BaseViewHolder> {

    private CircleImageView circleImageView;
    private TextView name_comment;
    private TextView title_comment;
    private LinearLayout ll_stars;

    public GoodsCommentAdapter(int layoutResId, @Nullable List<GoodsDetailBean.DataBean.CommentsBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, GoodsDetailBean.DataBean.CommentsBean item) {
        circleImageView = helper.getView(R.id.civ_comment_head);
//        ImageUtil.suitDisplay(circleImageView,1,1,750,55);
//        ImageUtil.suitMargin(circleImageView,0,24,24,24);
        GlideImgManager.loadImage(mContext,item.getUser_face(),circleImageView);

        name_comment = helper.getView(R.id.tv_comment_name);
//        ImageUtil.suitMargin(name_comment,0,38,0,38);
        helper.setText(R.id.tv_comment_name,item.getAuthor());

        ll_stars = helper.getView(R.id.ll_stars);
//        ImageUtil.suitMargin(ll_stars,0,36,0,42);
        switch (item.getRank()){
            case "1":
                helper.setImageResource(R.id.star_1,R.mipmap.star_red)
                        .setImageResource(R.id.star_2,R.mipmap.star_grey)
                        .setImageResource(R.id.star_3,R.mipmap.star_grey)
                        .setImageResource(R.id.star_4,R.mipmap.star_grey)
                        .setImageResource(R.id.star_5,R.mipmap.star_grey);
                break;
            case "2":
                helper.setImageResource(R.id.star_1,R.mipmap.star_red)
                        .setImageResource(R.id.star_2,R.mipmap.star_red)
                        .setImageResource(R.id.star_3,R.mipmap.star_grey)
                        .setImageResource(R.id.star_4,R.mipmap.star_grey)
                        .setImageResource(R.id.star_5,R.mipmap.star_grey);
                break;
            case "3":
                helper.setImageResource(R.id.star_1,R.mipmap.star_red)
                        .setImageResource(R.id.star_2,R.mipmap.star_red)
                        .setImageResource(R.id.star_3,R.mipmap.star_red)
                        .setImageResource(R.id.star_4,R.mipmap.star_grey)
                        .setImageResource(R.id.star_5,R.mipmap.star_grey);
                break;
            case "4":
                helper.setImageResource(R.id.star_1,R.mipmap.star_red)
                        .setImageResource(R.id.star_2,R.mipmap.star_red)
                        .setImageResource(R.id.star_3,R.mipmap.star_red)
                        .setImageResource(R.id.star_4,R.mipmap.star_red)
                        .setImageResource(R.id.star_5,R.mipmap.star_grey);
                break;
            case "5":
                helper.setImageResource(R.id.star_1,R.mipmap.star_red)
                        .setImageResource(R.id.star_2,R.mipmap.star_red)
                        .setImageResource(R.id.star_3,R.mipmap.star_red)
                        .setImageResource(R.id.star_4,R.mipmap.star_red)
                        .setImageResource(R.id.star_5,R.mipmap.star_red);
                break;

        }
        title_comment = helper.getView(R.id.tv_comment_title);
//        ImageUtil.suitMargin(title_comment,0,0,0,33);
        helper.setText(R.id.tv_comment_title,item.getContent());
    }
}
